namespace UniversalAdmin.Application.Common;

public class ApiResult<T>
{
  public bool Ok { get; set; }
  public int Code { get; set; }
  public string Message { get; set; } = string.Empty;
  public T? Data { get; set; }

  public static ApiResult<T> Success(T data, string? message = null)
  {
    return new ApiResult<T>
    {
      Ok = true,
      Code = 200,
      Message = message ?? string.Empty,
      Data = data
    };
  }

  public static ApiResult<T> Failure(int code, string message)
  {
    return new ApiResult<T>
    {
      Ok = false,
      Code = code,
      Message = message
    };
  }
}

public class PagedResult<T>
{
  public required List<T> Items { get; set; }
  public int TotalCount { get; set; }
  public int PageIndex { get; set; }
  public int PageSize { get; set; }
}